#!/usr/bin/env python
# encoding: utf-8

import os

basedir = os.path.abspath(os.path.dirname(__file__))

# 基类
class Config:
    DEBUG = False

    SECRET_KEY = '''\xfd{H\xe5<\x95\xf9\xe3\x96.5\xd1\x01O<!\xd5\xa2\xa0\x9fR"\xa1\xa8'''

    TEMPLATES_AUTO_RELOAD = True

    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    MQTT_BROKER_URL = 'localhost'
    MQTT_BROKER_PORT = 1883
    MQTT_USERNAME = ''
    MQTT_PASSWORD = ''
    MQTT_KEEPALIVE = 60
    MQTT_TLS_ENABLED = False

    SERIAL_TIMEOUT = 0.1  # make sure that the alive event can be checked from time to time
    SERIAL_PORT = 'COM1'
    SERIAL_BAUDRATE = 115200
    SERIAL_BYTESIZE = 8
    SERIAL_PARITY = 'N'
    SERIAL_STOPBITS = 1

    @staticmethod
    def init_app(app):
        pass

# 开发环境
class DevelopmentConfig(Config):
    DEBUG = True
    # SQLALCHEMY_DATABASE_URI = 'mysql+mysqldb://root:#Sczc01020304@localhost:3306/nrs_stock'
    # SQLALCHEMY_DATABASE_URI = 'mysql+mysqldb://root:#Sczc01020304@47.96.188.120:3306/nrs_stock'
    # SQLALCHEMY_DATABASE_URI = 'mysql+mysqldb://xiong:#Redfalsh192729@47.96.188.120:3306/nrs_stock'
    SQLALCHEMY_DATABASE_URI = 'sqlite:///%s/test.db' % basedir

# 测试环境
class TestingConfig(Config):
    TESTING = True
    SQLALCHEMY_DATABASE_URI = 'mysql+mysqldb://xiong:#Redfalsh192729@47.96.188.120:3306/nrs_stock_test'

# 生产环境
class ProductionConfig(Config):
    SQLALCHEMY_DATABASE_URI = 'mysql://root:#Sczc01020304@localhost:3306/nrs_test'

# 设置一个config 字典中,注册了不同的配置环境
config = {
'development': DevelopmentConfig,
'testing': TestingConfig,
'production': ProductionConfig,
'default': DevelopmentConfig
}
